package cpe.hapa.model;

import java.util.Date;

import com.google.appengine.api.datastore.Key;

public class User {
	private Key key;
	private String nom;
	private String prenom;
	private Date dateNaissance;
	private String email;
	private String login;
	private String password;
	private String role;
	private Boolean isPasswordChanged;
	private Date dateConnexion;
	private Date dateCreation;
	private Long dureeConnexion;
	
	public User(Key key, String nom, String prenom, Date dateNaissance,
			String email, String login, String password, String role,
			Boolean isPasswordChanged, Date dateConnexion, Long dureeConnexion, Date dateCreation) {
		super();
		this.key = key;
		this.nom = nom;
		this.prenom = prenom;
		this.dateNaissance = dateNaissance;
		this.email = email;
		this.login = login;
		this.password = password;
		this.role = role;
		this.isPasswordChanged = isPasswordChanged;
		this.dateConnexion = dateConnexion;
		this.dureeConnexion = dureeConnexion;
		this.dateCreation = dateCreation;
	}

	public Boolean isInRole(String role) {
		if (this.role.equals("admin")) {
			return true;
		} else {
			return this.role.equals(role);
		}
	}
	
	public Date getDateCreation() {
		return dateCreation;
	}

	public void setDateCreation(Date dateCreation) {
		this.dateCreation = dateCreation;
	}

	public void setDureeConnexion(Long dureeConnexion) {
		this.dureeConnexion = dureeConnexion;
	}
	public Key getKey() {
		return key;
	}
	public void setKey(Key key) {
		this.key = key;
	}
	public String getNom() {
		return nom;
	}
	public void setNom(String nom) {
		this.nom = nom;
	}
	public String getPrenom() {
		return prenom;
	}
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
	public Date getDateNaissance() {
		return dateNaissance;
	}
	public void setDateNaissance(Date dateNaissance) {
		this.dateNaissance = dateNaissance;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getLogin() {
		return login;
	}
	public void setLogin(String login) {
		this.login = login;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getRole() {
		return role;
	}
	public void setRole(String role) {
		this.role = role;
	}
	public Boolean isPasswordChanged() {
		return isPasswordChanged;
	}
	public void setIsPasswordChanged(Boolean isPasswordChanged) {
		this.isPasswordChanged = isPasswordChanged;
	}
	public Date getDateConnexion() {
		return dateConnexion;
	}
	public void setDateConnexion(Date dateConnexion) {
		this.dateConnexion = dateConnexion;
	}
	public Long getDureeConnexion() {
		return dureeConnexion;
	}
}
